

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/2.jpg">
  <link rel="icon" type="image/png" href="/img/2.jpg">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="">
  <meta name="author" content="K">
  <meta name="keywords" content="">
  <title>hexo博客搭建 - K</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/github-gist.min.css" />
    
  

  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.2.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>かい</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner intro-2" id="background" parallax=true
         style="background: url('/img/1.jpg') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container page-header text-center fade-in-up">
            <span class="h2" id="subtitle">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2020-03-08 18:27" pubdate>
        2020年3月8日 晚上
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      846 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      10
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto" id="post">
            <!-- SEO header -->
            <h1 style="display: none">hexo博客搭建</h1>
            
            <div class="markdown-body" id="post-body">
              <h2 id="Hexo"><a href="#Hexo" class="headerlink" title="Hexo"></a>Hexo</h2><ul>
<li><p>概述</p>
<ol>
<li>快速，简单且功能强大的博客框架</li>
<li> 一键部署，您只需一个命令即可将您的站点部署到GitHub Pages，Heroku或其他平台</li>
<li>降价支持，支持GitHub Flavored Markdown的所有功能，包括大多数Octopress插件。</li>
<li>快速构建，由Node.js提供支持的令人难以置信的生成速度。数百个文件仅需几秒钟即可构建。</li>
<li>具有功能强大的API，可实现无限扩展。各种插件可用于支持大多数模板引擎（EJS，Pug，Nunjucks等）。轻松与现有NPM软件包（Babel，PostCSS，Less / Sass等）集成</li>
<li>Hexo是一个快速，简单且功能强大的博客框架。您使用Markdown（或其他标记语言）编写帖子，然后Hexo会在几秒钟内生成带有精美主题的静态文件</li>
</ol>
<ul>
<li><p>安装需求</p>
<table>
<thead>
<tr>
<th>node.js</th>
<th>Git</th>
</tr>
</thead>
</table>
<p>需要这两个插件的支持<br>node.js 至少应为Node.js 8.10，建议为10.0或更高版本<br>Git 安装稳定版本</p>
</li>
</ul>
</li>
</ul>
<h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2><ul>
<li><p>安装 Git</p>
<p>  Windows：下载并安装git。</p>
<p>  Mac：使用Homebrew，MacPorts或installer进行安装。</p>
<p>  Linux（Ubuntu，Debian）： </p>
  <pre><code class="hljs routeros">sudo apt-<span class="hljs-builtin-name">get</span> install git-core</code></pre>
<p>  Linux（Fedora，Red Hat，CentOS）： </p>
 <pre><code class="hljs cmake">sudo yum <span class="hljs-keyword">install</span> git-core</code></pre>
<p> 安装Git时对于Mac用户<br> 编译时可能会遇到一些问题。请先从App Store安装Xcode。安装Xcode后，打开Xcode并转到“首选项”-&gt;“下载”-&gt;“命令行工具”-&gt;“安装”以安装命令行工具。</p>
<ul>
<li><p>安装 node.js<br>Node.js 为大多数平台提供了官方安装程序。</p>
<p>Windows：浏览器搜索 node.js 进官方下载安装包<br>Mac：使用Homebrew或MacPorts安装它。<br>Linux（基于DEB / RPM）：与NodeSource一起安装。<br>其他：通过相应的软件包管理器进行安装。请参阅Node.js提供的指南。</p>
</li>
</ul>
</li>
<li><p>安装 hexo博客框架<br> 由于在国内下载框架非常慢，所以我们用淘宝的cnpm下载 博客框架</p>
  <pre><code class="hljs awk">npm install -g cnpm --registry=https:<span class="hljs-regexp">//</span>registry.npm.taobao.org   <span class="hljs-comment">#下载淘宝的cnpm</span>
cnpm -v <span class="hljs-comment"># 下载好查看版本号</span></code></pre>
<p>  接下来在你喜欢的一个磁盘里创建一个博客目录</p>
  <pre><code class="hljs routeros">mkdir [博客目录名]
cd [博客目录名]
cnpm install -g hexo-cli #安装hexo博客框架
hexo init #初始化hexo博客，就是将这个目录变成博客目录
hexo<span class="hljs-built_in"> server </span>启动博客</code></pre>

<p>  启动后访问 <a target="_blank" rel="noopener" href="http://localhost:4000/">http://localhost:4000/</a>  然后就出现了这个页面<br>  <img src="/images/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA1.jpg" srcset="/img/loading.gif"><br>  这样博客就部署好了,我们现在发布一个文章</p>
<p>  操作：</p>
  <pre><code class="hljs jboss-cli">hexo new <span class="hljs-string">&quot;我的第一篇博客&quot;</span> <span class="hljs-comment">#创建博客</span>
<span class="hljs-keyword">cd</span> [博客目录名称]<span class="hljs-string">/source/_posts</span>  <span class="hljs-comment">#这里面试存放文章的目录</span>
vim 我的第一篇博客<span class="hljs-string">.md</span>
</code></pre>
  <pre><code class="hljs yaml">     <span class="hljs-string">---</span>
 <span class="hljs-attr">title:</span> <span class="hljs-string">我的第一篇博客</span>
 <span class="hljs-attr">date:</span> <span class="hljs-number">2020-03-08 19:39:15</span>
 <span class="hljs-attr">tags:</span>
 <span class="hljs-string">---</span>

 <span class="hljs-comment">## 第一章</span>

 <span class="hljs-comment">## 第二章</span>

 <span class="hljs-comment">## 小结 </span>

<span class="hljs-string">wq保存退出</span></code></pre>
  <pre><code class="hljs routeros">hexo clean 
hexo generate
hexo server
curl localhost:4000/</code></pre>
<p>  <img src="/images/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA2.jpg" srcset="/img/loading.gif"></p>
</li>
<li><p>将博客部署到github上<br> 在github上创建仓库<br> 复制 仓库地址<br> 在博客跟目录找到并打开 _config.yml</p>
 <pre><code class="hljs awk"> <span class="hljs-comment"># Deployment</span>
<span class="hljs-comment">## Docs: https://hexo.io/docs/deployment.html</span>
deploy:
type: <span class="hljs-string">&#x27;git&#x27;</span> <span class="hljs-comment">#修改</span>
repo: https:<span class="hljs-regexp">//gi</span>thub.com<span class="hljs-regexp">/LMK-hacker/</span>LMK-hacker.github.io.git  <span class="hljs-comment">#github仓库地址</span>
branch: master <span class="hljs-comment">#分支设置为 master</span></code></pre>
<p>修改完成后，clean generate 部署到远端（deploy）</p>
<pre><code class="hljs verilog">hexo clean
hexo <span class="hljs-keyword">generate</span>
cnpm install --save hexo-deployer-git  #安装git部署的插件
hexo deploy
curl  https:<span class="hljs-comment">//lmk-hacker.github.io/ #访问博客地址</span></code></pre>

</li>
</ul>
<h2 id="小结"><a href="#小结" class="headerlink" title="小结"></a>小结</h2><p>hexo 设置文章 分类，标签，归档</p>
<pre><code class="hljs dts"><span class="hljs-symbol">menu:</span>
<span class="hljs-symbol">  home:</span> /      <span class="hljs-meta">#主页</span>
<span class="hljs-symbol">  categories:</span> /categories <span class="hljs-meta">#分类</span>
<span class="hljs-symbol">  archives:</span> /archives   <span class="hljs-meta">#归档</span>
<span class="hljs-symbol">  tags:</span> /tags   <span class="hljs-meta">#标签  </span>
<span class="hljs-symbol">  about:</span> /about   <span class="hljs-meta">#关于</span>
<span class="hljs-symbol">  guestbook:</span> /guestbook    <span class="hljs-meta">#自定义</span></code></pre>
            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/categories/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/">博客搭建</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/Home/">Home</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章是以学习为目的，如果有不对的地方可以一起交流沟通共同学习 邮箱:1248287831@qq.com！</p>
              
              
                <div class="post-prevnext row">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2020/03/10/git%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6%E7%B3%BB%E7%BB%9F/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">Git版本控制系统</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2020/03/08/%E6%B5%8B%E8%AF%95/">
                        <span class="hidden-mobile">测试</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://space.bilibili.com/39165374" target="_blank" rel="nofollow noopener"><span>LMK</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


  

  
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/js/debouncer.js" ></script>
<script  src="/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/js/lazyload.js" ></script>
  



  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/js/clipboard-use.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: '#post-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "hexo博客搭建&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/js/local-search.js" ></script>
  <script>
    var path = "/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>















</body>
</html>
